/**
 * 
 */
package com.base.myproject.client.system;

import java.util.Set;

import com.base.myproject.client.busi.BaseStore;
import com.extjs.gxt.ui.client.data.BaseModelData;

/**
 * 系统信息
 * 
 * @author zgw 2009-8-12 下午01:38:54 javazgw@gmail.com
 */
public final class SystemMessage {
	static SystemMessage systemmessage = null;
	static final public String managercenterwidth = "720px";
	//界面高度
	static final public String managercenterheight = "700px";
	static final public String leftheight = "680px";
	static final public int fullwidthinmain = 900;
	static final public int fullheightinmain = 700;
	private SystemMessage()
	{
		
	}
	
	public static SystemMessage getInstance()
	{
		if(systemmessage==null)
		{
			systemmessage = new SystemMessage();
		}
		return systemmessage;
	}
//1
	static final String[] RPC_Message = new String[] { "RPC_SUCCESS",// 和服务器通信获得成功结果的发送或者返回值
			"RPC_FALSE"// 和服务器通信获得失败结果的发送或者返回值

	};
//2
	static final String[] RPC_COMMAND_Message = new String[] { "SHOPINGCAR_SAVE",// 购物车保存事件
		"SHOPINGCAR_DELETE",// 和服务器通信获得失败结果的发送或者返回值
		"SHOPINGCAR_ADDITEMBYID", //通过id号将商品加入购物车
		"ADDSUIT",//B2c,添加套装商品；
		"DELETESUIT",//B2c,删除套装商品；
};
//4
	static final String[] INFO_MESSAGE = new String[]{
		"保存成功",//0通用的保存成功返回提示信息。通常不该此信息。
		"保存失败",//1
		"数据格式录入错误",//2
		"删除成功",//3通用的删除成功返回提示信息。通常不该此信息。
		"删除失败",//4
		"获得主键错误，删除失败",//5
		"同时高过一个商品被加入购物车",//6
		"成功加入购物车",//7
		"加入购物车失败",//8
		"添加成功",//9
		"添加失败"//10
	};
//5 
	static public java.util.Map<String, String> statusmap = new java.util.HashMap<String, String>(); 
	static {
		statusmap.put("1", "准备");
		statusmap.put("2", "取消");//单据取消状态
		statusmap.put("4", "");
		statusmap.put("8", "等待备货");
		statusmap.put("16", "备货完毕");
		statusmap.put("32", "取消备货");
		statusmap.put("64", "");
		statusmap.put("128", "服务中"); //service中有用
		statusmap.put("256", "");
		
		statusmap.put("512", "");
		statusmap.put("1024", "");
		statusmap.put("2048", "已提交");
		statusmap.put("4096", "");
		statusmap.put("8192", "");
		statusmap.put("16384", "");
		statusmap.put("32768", "");
		statusmap.put("65536", "");
		statusmap.put("131072", "执行");
		statusmap.put("262144", "");
		statusmap.put("524288", "完成");//service中有用
		statusmap.put("1048576", "");
		
	}
	//6
	public static final String[] busi=new String[]{
			"1001", //采购合同  0
			"1002", //销售合同 1 
			"1010",//发货单 2
			"1100",//库存备货，入库准备  3
			"1105",//入库  4
			"1110",//出库准备 5
			"1115",//出库完成  6
			"1120",//供应商备货 7
			"6001", //会员正在接受服务 8
			"6005", //预约，美容美发 9
			"8001" //hr,薪金项目定义10
			
	};
	//7
	static BaseStore<BaseModelData> bs = null;
	public  BaseStore<BaseModelData> getStatusBaseStore()
	{
		
		if(bs==null)
		{ bs =new  BaseStore<BaseModelData>();
			Set<String> key = statusmap.keySet();
			for(String str :key)
			{
				BaseModelData bmd=new BaseModelData();
				bmd.set("code",str);
				bmd.set("name", statusmap.get(str));
				if(!(statusmap.get(str).equals("")))
				bs.add(bmd,false,false);
			}
		}
		return bs;
	}
	public static String getMessage(int mode, int index) {
		if (mode == 1) {
			if (RPC_Message.length < index + 1) {
				throw new java.lang.RuntimeException("数组越界");
			} else {
				return RPC_Message[index];
			}
		}
		else if (mode == 2) {
			if (RPC_COMMAND_Message.length < index + 1) {
				throw new java.lang.RuntimeException("数组越界");
			} else {
				return RPC_COMMAND_Message[index];
			}
		}

		else if (mode == 4) {
			if (INFO_MESSAGE.length < index + 1) {
				throw new java.lang.RuntimeException("数组越界");
			} else {
				return INFO_MESSAGE[index];
			}
		}

		return "";

	}
	/**
	 * @return the statusmap
	 */
	public static java.util.Map<String, String> getStatusmap() {
		return statusmap;
	}
	/**
	 * @param statusmap the statusmap to set
	 */
	public static void setStatusmap(java.util.Map<String, String> statusmap) {
		SystemMessage.statusmap = statusmap;
	}
	public static String getstatus(String key)
	{
		
		if(!(statusmap.containsKey(key)))
			return "未找到对应";
		return statusmap.get(key);
	}
	
}
